package cn.lsq.org.service.impl;

import cn.lsq.basic.utils.PageList;
import cn.lsq.org.domain.Logininfo;
import cn.lsq.org.mapper.LogininfoMapper;
import cn.lsq.org.query.LogininfoQuery;
import cn.lsq.org.service.LogininfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class LogininfoServiceImpl implements LogininfoService {
    @Autowired
    private LogininfoMapper logininfoMapper;
    @Override
    public List<Logininfo> loadAll() {
        return logininfoMapper.loadAll();
    }

    @Override
    public Logininfo loadById(Long id) {
        return logininfoMapper.loadById(id);
    }
    @Transactional
    @Override
    public void save(Logininfo logininfo) {
        logininfoMapper.save(logininfo);
    }
    @Transactional
    @Override
    public void remove(Long id) {
        logininfoMapper.remove(id);
    }
    @Transactional
    @Override
    public void update(Logininfo logininfo) {
        logininfoMapper.update(logininfo);
    }

    @Override
    public PageList<Logininfo> queryPage(LogininfoQuery logininfoQuery) {
        Long count = logininfoMapper.queryCount(logininfoQuery);
        if (count == 0){
            return new PageList<>();
        }
        List<Logininfo> logininfos = logininfoMapper.queryData(logininfoQuery);
        return new PageList<Logininfo>(count,logininfos);
    }
    @Override
    public void patchDelete(Long[] ids) {
        logininfoMapper.patchDelete(ids);
    }
}
